package com.ming.sevice.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ming.mapper.HotSearchMapper;
import com.ming.domain.HotSearch;
import com.ming.sevice.HotSearchService;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

/**
 *@Author:何元才
 *@Desc:
 *@data:2021-04-02 15:48
 */
@Service
public class HotSearchServiceImpl extends ServiceImpl<HotSearchMapper, HotSearch> implements HotSearchService{

    @Autowired
    private HotSearchMapper hotSearchMapper;
    /**
     * 热搜分页查询
     *
     * @param page
     * @param hotSearch
     * @return
     */
    @Override
    public Page<HotSearch> findNoticePage(Page<HotSearch> page, HotSearch hotSearch) {
        return hotSearchMapper.selectPage(page , new LambdaQueryWrapper<HotSearch>()
                .eq(ObjectUtils.isEmpty(hotSearch.getStatus()), HotSearch::getStatus, hotSearch.getStatus())
                .like(StringUtils.hasText(hotSearch.getTitle()),HotSearch::getTitle,hotSearch.getTitle())
                .like(StringUtils.hasText(hotSearch.getContent()), HotSearch::getContent, hotSearch.getContent())
                .orderByDesc(HotSearch::getSeq)

        );
    }
}
